package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.KuaiDiJieGuoDataEntity;

/**
 * 快递查询适配器
 * Created by admin on 2016/10/24.
 */

public class KuaiDiAdapter extends RecyclerView.Adapter<KuaiDiAdapter.ViewHolder> {
    private Context context;
    private KuaiDiJieGuoDataEntity kuaiDiJieGuoDataEntity;

    public KuaiDiAdapter(Context context, KuaiDiJieGuoDataEntity kuaiDiJieGuoDataEntity) {
        this.context = context;
        this.kuaiDiJieGuoDataEntity = kuaiDiJieGuoDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_kuaidichaxun, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_item_kuaidi_time.setText(kuaiDiJieGuoDataEntity.getShowapi_res_body().getData().get(position).getTime());
        holder.tv_item_kuaidi_content.setText(kuaiDiJieGuoDataEntity.getShowapi_res_body().getData().get(position).getContext());
    }

    @Override
    public int getItemCount() {
        return kuaiDiJieGuoDataEntity.getShowapi_res_body().getData().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_item_kuaidi_time;// 快递时间
        private TextView tv_item_kuaidi_content;// 快递事件

        public ViewHolder(View itemView) {
            super(itemView);
            tv_item_kuaidi_time = (TextView) itemView.findViewById(R.id.tv_item_kuaidi_time);
            tv_item_kuaidi_content = (TextView) itemView.findViewById(R.id.tv_item_kuaidi_content);
        }
    }
}
